using System;

namespace Rob.SampleCode.MyApp.Core.Presentation
{
    public interface IGenerateErrorView
    {
        void NotifyUser(string message);
    }

    public class GenerateErrorPresenter
    {
        public GenerateErrorPresenter(IGenerateErrorView view) : this(view, Ioc.Resolve<IRepository>())
        {
        }

        public GenerateErrorPresenter(IGenerateErrorView view, IRepository repository)
        {
            _view = view;
            _repository = repository;
        }

        private readonly IGenerateErrorView _view;
        private readonly IRepository _repository;

        public void Initialize()
        {
        }

        public void ThrowNIE()
        {
            throw new NotImplementedException();
        }

        public void ThrowNullReferenceException()
        {
            throw new NullReferenceException();
        }

        public void HandleException()
        {
            try
            {
                throw new ArgumentNullException();
            }
            catch (Exception ex)
            {
                _view.NotifyUser("Error just occurred: " + ex);
            }
        }
    }
}